package cn.lili.controller.promotion;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.BlindboxRuleOrder;
import cn.lili.modules.promotion.entity.dto.BlindboxRuleOrderDTO;
import cn.lili.modules.promotion.entity.dto.CallbackBlindboxDTO;
import cn.lili.modules.promotion.service.BlindboxCountService;
import cn.lili.modules.promotion.service.BlindboxRuleOrderService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;


/**
 * @author xiangqian
 */
@RestController
@Api(tags = "盲盒统计接口")
@RequestMapping("/promotion/blindbox/count")
@RequiredArgsConstructor
public class BlindboxCountController {

    private final BlindboxCountService blindboxCountService;
    private final BlindboxRuleOrderService blindboxRuleOrderService;

    @ApiOperation(value = "下单后更新盲盒统计--临时测试使用")
    @PostMapping("/callbackBlindbox")
    public ResultMessage<Object> callbackBlindbox(@RequestBody CallbackBlindboxDTO callbackBlindboxDTO) {
        Boolean falg = blindboxCountService.callbackBlindbox(callbackBlindboxDTO);
        return ResultUtil.data(falg);
    }

    /**
     * 查询最新中奖名单
     *
     * @param page
     */
    @ApiOperation(value = "查询最新中奖名单")
    @GetMapping("/getUpPrizeList")
    public ResultMessage<Page<BlindboxRuleOrderDTO>> getUpPrizeList(PageVO page) {
        return ResultUtil.data(blindboxRuleOrderService.getUpPrizeList(page));
    }
}
